<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>排他思想</title>
</head>

<body>


    <button>a</button>
    <button>a</button>
    <button>a</button>
    <button>a</button>
    <button>a</button>

</body>

<script>
    var b = document.getElementsByTagName('button');




    for (var i = 0; i < b.length; i++) {
        b[i].onclick = function() {
            this.style.backgroundColor = 'red';
        }


        b[i].onblur = function() {
            this.style.backgroundColor = '';
        }
    }
</script>

</html>